import request from '@/utils/request';
import requestSSO from '@/utils/request-sso';

// 查询授权信息
export function getApiList(data) {
    return request({
      url: 'auth/getAuthPages',
      method: 'post',
      data
    })
  }

// 新增授权信息
export function insertAuth(data) {
    return request({
        url: 'auth/insertAuth',
        method: 'post',
        data
    })
}

// 修改授权信息
export function updateAuth(data) {
    return request({
      url: 'auth/updateAuth',
      method: 'post',
      data
    })
  }

// 删除授权信息
export function deleteAuth(data) {
  return request({
    url: 'auth/deleteAuth',
    method: 'post',
    data
  })
}

//  查询角色列表
export function getSysRoleListsByCode(data, pageNum, pageSize) {
  return requestSSO({
    url: `/api/v1/sysRole/list?page=${pageNum}&pageSize=${pageSize}`,
    method: 'POST',
    data
  })
}

// 创建角色
export function insertSysRoleByCode(data) {
  return requestSSO({
    url: `/api/v1/sysRole/insert`,
    method: 'POST',
    data
  })
}

// 修改角色
export function updateSysRoleByCode(data) {
  return requestSSO({
    url: `/api/v1/sysRole/update`,
    method: 'POST',
    data
  })
}

// 删除角色
export function deleteSysRoleById(id) {
  return requestSSO({
    url: `/api/v1/sysRole/delete/${id}`,
    method: 'delete'
  })
}

// 查询角色详情
export function getSysRoleById(id) {
  return requestSSO({
    url: `/api/v1/sysRole/get/${id}`,
    method: 'GET'
  })
}

//  给角色绑定用户
export function bindUserIdSysUserRole(data, roleId) {
  return requestSSO({
    url: `/api/v1/sysUserRole/insert?roleId=${roleId}`,
    method: 'POST',
    data
  })
}

// 角色与用户解绑
export function unbindUserIdSysUserRole(userId,roleId) {
  return requestSSO({
    url: `/api/v1/sysUserRole/delete?userId=${userId}&roleId=${roleId}`,
    method: 'DELETE'
  })
}


// 查询这个角色都有哪些用户
export function getSysUserRoleList(id) {
  return requestSSO({
    url: `/api/v1/sysUserRole/list/byRoleId/${id}`,
    method: 'GET',
  })
}





